package store.lunangangster.nodeflow.parser.factory.el;

import store.lunangangster.nodeflow.parser.base.XmlFlowParser;
import store.lunangangster.nodeflow.parser.el.ELXmlFlowParser;
import store.lunangangster.nodeflow.parser.factory.ParserFactory;

/**
 * 基于EL表达式的RuleSource文件解析类的工厂类
 *
 * @author cwk
 * @version 1.0
 */
public class ELParserFactory implements ParserFactory {

  private static volatile ELXmlFlowParser elXmlFlowParser;

  @Override
  public XmlFlowParser newXmlFlowParser() {
    elXmlFlowParser = new ELXmlFlowParser();
    return elXmlFlowParser;
  }

  @Override
  public XmlFlowParser getXmlFlowParser() {
    if (elXmlFlowParser == null) {
      synchronized (this) {
        if (elXmlFlowParser == null) {
          return newXmlFlowParser();
        }
      }
    }
    return elXmlFlowParser;
  }
}
